package com.gjy.reflect;

import org.junit.jupiter.api.Test;

import java.lang.reflect.Field;

/**
 * @author 宫静雨
 * @version 1.0
 * @since 2023-03-14 09:08:28
 */
public class Ref1Test {

    @Test
    public void test1() throws NoSuchFieldException {
        Class<T2> cls = T2.class;

        Field[] fields = cls.getDeclaredFields();
        for (Field field : fields) {
            System.out.println("field.getName() = " + field.getName());
        }

        Field f1 = cls.getField("f1");
        System.out.println("f1.getName() = " + f1.getName());
    }

    private static class T1 {
        public String f1;
    }

    private static class T2 extends T1 {
        public Integer f2;
    }

}
